#import "SEGUserauditManager.h"

#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif
#if __has_include(<Commom/SEGHTTPBusinessManager.h>)
#import <Commom/SEGHTTPBusinessManager.h>
#else
#import "SEGHTTPBusinessManager.h"
#endif

static id _UserAuditManager;
static dispatch_once_t onceToken;

@implementation SEGUserauditManager
#pragma mark - SINGLE----BEGIN----
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _UserAuditManager = [[self alloc] init];
    });
    return _UserAuditManager;
}

+(void)destroyResource{
    onceToken = 0;
    _UserAuditManager = nil;
}

#pragma mark - SINGLE----END----

#pragma mark - HTTP----BEGIN----
//operate :1：拒绝；2：通过
// 最新：操作（1：同过；5：审核未通过）
-(void)requestUserauditWithUsercustrelids:(NSString*)userCustRelIds operate:(NSString*)operate roleId:(NSString*)roleId finished:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))finished{
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:userCustRelIds forKey:@"enterpriseUserIds"];
    [params setValue:operate forKey:@"operate"];
//    if (roleId && roleId.length > 0) {
        [params setValue:roleId forKey:@"roleId"];
//    }
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/enterprise-app/user/audit.json",nil];
    [SEGHTTPBusinessManager seg_requestJSONWithMethod:POST URLString:urlString parameters:params completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            finished(isSuccessed,nil,codeType,error.localizedDescription);
            return;
        }
        
        self.UserAudit = [SEGUserauditModel yy_modelWithDictionary:result];
        finished(isSuccessed,result,codeType,error.localizedDescription);
        return;
    }];
}
#pragma mark - HTTP----END----

#pragma mark - GETTER----BEGIN----
-(SEGUserauditModel *)UserAudit{
    if (!_UserAudit) {
        _UserAudit = [[SEGUserauditModel alloc]init];
    }
    return _UserAudit;
}
#pragma mark - GETTER----END----
@end

